﻿using System;
using System.Text;
using UnityEngine;

public class PubliciteDirectore: MonoBehaviour
{
    public static PubliciteDirectore exemple;
    private Action adSuccess;
    private bool canShowInterstitial;
    public string prev;
    public byte configKey;
    public string publiciteKey;

    private void Awake()
    {
        PubliciteDirectore.exemple = this;
    }

    private void Start()
    {
        byte[] bytes = Convert.FromBase64String(this.prev);
        for (int i = 0; i < bytes.Length; ++i)
        {
            bytes[i] = (byte) (bytes[i] ^ (uint) this.configKey);
        }
        this.publiciteKey = Encoding.UTF8.GetString(bytes);

        if (this.GDPR_ACCEPTE == 0)
        {
            this.GDPR_ACCEPTE = 1;
        }

        this.verificadetemps(30);
    }

    public void verificadetemps(int delayTime)
    {
        this.canShowInterstitial = false;
        this.CancelInvoke("ouiouioui");
        this.Invoke("ouiouioui", delayTime);
    }

    private void ouiouioui()
    {
        this.canShowInterstitial = true;
    }

    public void montrerInterstitiel()
    {
        this.verificadetemps(40);
    }

    public void onIncentivizedAdSuccess()
    {
        this.verificadetemps(40);
        if (this.adSuccess != null)
        {
            this.adSuccess();
            this.adSuccess = null;
        }
    }

    private int GDPR_ACCEPTE
    {
        get
        {
            return PlayerPrefs.GetInt(nameof(GDPR_ACCEPTE), 0);
        }
        set
        {
            PlayerPrefs.SetInt(nameof(GDPR_ACCEPTE), value);
        }
    }

    public bool isAmazingAdAvailable()
    {
        return false;
    }

    public void yeaahhh()
    {
    }

    public void yeaahhh2()
    {
    }
}